// packageStore/pages/purchase/orderoffine/detail.js
var app = getApp();
import { api} from '../../../../js/util'
import { orderlist } from "../../../../js/modules/order.js"
import { alert, isEmpty } from '../../../../js/newUtil';
const pageBehavior = require('../../../../js/common/PageBehavior')

Page({
  behaviors: [pageBehavior],
  pageKey:"orderOffine",
  /**
   * 页面的初始数据
   */
  data: {
    imgDomain: api.imgDomain,
    enableOss: api.enableOss,
    oddNumber:'',
    detailList:{},
    headerBg:"",
    Currency:'',//货币符号
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      oddNumber:options.oddNumber
    })
    this.loadList();
  },
  loadList(){
    var that = this;
    var param = {
      PageIndex:1,
      PageSize:6,
      keywords:that.data.oddNumber
    };
    orderlist.offlineData(-1, param, function(content, fkid) {
      var data = content.data;
      console.log(data,'-----===data');
      for(var i=0;i<data.length;i++){
        if(data[i].OrderCode == that.data.oddNumber){
          that.setData({
            detailList:data[i]
          });
        }
      }
      if (isEmpty(data)) {
        alert({
          content: '未获取到信息',
          success () {
            wx.navigateBack()
          }
        })
      }
      //如果key为变量作为key值的时候要用[]包裹起来
     
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      headerBg:api.titleColor||"#e56b14",
      Currency:api.Currency || '￥'
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})